package com.itheima.web;

import com.itheima.dao.AccountDao;
import com.itheima.domain.Account;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.xml.ws.soap.Addressing;
import java.util.List;

/**
 * Created by crowndint on 2018/10/1.
 */
@RestController
@RequestMapping("account")
@ConfigurationProperties(prefix = "data")
public class AccountController {

    @Autowired
    private AccountDao accountDao;

    @RequestMapping("findAll")
    public List<Account> findAll() {

        return accountDao.findAll();
    }

    private List<Account> accounts;

    public void setAccounts(List<Account> accounts) {
        this.accounts = accounts;
        System.out.println("setAccounts()");
        for (Account account : accounts) {
            System.out.println(account);
        }
    }

    @RequestMapping("findAllFromConfig")
    public List<Account> findAllFromConfig() {

        return this.accounts;
    }
}
